Use scatter plot to compare two variable of interest from CMAP.

Specify following parameters to retrieve required data.

In addition to this, specify “agg.var” parameter to aggregate the variable of interest, and align the data from the two tables. For example, we select agg.var = “time”.

plot_xy function download the data, and output a list which contain a) plot object: plot_ly/ggplot; b) corresponding data tables.

con <- dbConnect(odbc::odbc(), DSN="CMAP-MSSQL",UID="ArmLab",PWD="ArmLab2018")
# Inpit variable:
# 
table.list <- c('tblSST_AVHRR_OI_NRT', 'tblAltimetry_REP') 
var.list <-  c('sst', 'sla')  
#
range.var <- list()
range.var$lat <- c(25,30)
range.var$lon <- c(-160, -155)
range.var$time <- c('2016-03-29', '2016-05-29')
#
agg.var <- 'time' 

## -----------------------------------
## Dataset from table II
selIndex <- 1
table.name <- table.list[selIndex]                       # Specify table name I
sel.var <- var.list[selIndex]                            # Variable from table name I  

tbl.subset.x <- getAggregatedTableData(con, table.name, sel.var, range.var, agg.var)
head(tbl.subset.x)
## # A tibble: 6 x 2
##   time         sst
##   <date>     <dbl>
## 1 2016-03-29  21.3
## 2 2016-03-30  20.6
## 3 2016-03-31  20.6
## 4 2016-04-01  20.7
## 5 2016-04-02  20.8
## 6 2016-04-03  20.9
## Dataset from table II
selIndex <- 2
table.name <- table.list[selIndex]                       # Specify table name II
sel.var <- var.list[selIndex]                            # Variable from table name II


tbl.subset.y <- getAggregatedTableData(con, table.name, sel.var, range.var, agg.var)
head(tbl.subset.y)
## # A tibble: 6 x 2
##   time          sla
##   <date>      <dbl>
## 1 2016-03-29 0.0242
## 2 2016-03-30 0.0228
## 3 2016-03-31 0.0215
## 4 2016-04-01 0.0208
## 5 2016-04-02 0.0197
## 6 2016-04-03 0.0189
## Plot - XY
# out <- plot_xy(con, table.list,var.list,range.var,agg.var,type = 'ggplot')
out <- plot_xy(con, table.list,var.list,range.var,agg.var,type = 'plotly')
out$plot
dbDisconnect(con)